class Solution:
    def majorityElement(self, nums: List[int]) -> int:
        vote, x = 0, nums[0]
        for num in nums:
            if vote == 0:
                x = num
            vote += 1 if num == x else -1
        return x